package com.example.demo.controller.common;

import com.example.demo.common.IdParam;
import com.example.demo.domain.entity.VojLanguages;
import com.example.demo.dto.ItemDto;
import com.example.demo.dto.ProblemCategoryDto;
import com.example.demo.dto.ResponseDto;
import com.example.demo.param.voj.VojCategorySaveParam;
import com.example.demo.service.CommonService;
import com.example.demo.service.VojProblemCategoriesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公共接口
 */
@Controller
@RequestMapping("/common")
public class CommonController {

    private static final Logger log = LoggerFactory.getLogger(CommonController.class);

    @Resource
    private CommonService commonService;

    /**
     * 下拉框 - 语言
     * @return
     */
    @RequestMapping("/getLanguage")
    @ResponseBody
    public ResponseDto<List<ItemDto>> getLanguage() {
        List<ItemDto> data = commonService.getLanguage();
        ResponseDto<List<ItemDto>> result = new ResponseDto().buildSucceedHasData(data);
        return result;
    }

    /**
     * 下拉框 - 公司
     * @return
     */
    @RequestMapping("/getCompany")
    @ResponseBody
    public ResponseDto<List<ItemDto>> getCompany() {
        List<ItemDto> data = commonService.getCompany();
        ResponseDto<List<ItemDto>> result = new ResponseDto().buildSucceedHasData(data);
        return result;
    }
    /**
     * 下拉框 - 分类
     * @return
     */
    @RequestMapping("/getCategory")
    @ResponseBody
    public ResponseDto<List<ItemDto>> getCategory() {
        List<ItemDto> data = commonService.getCategory();
        ResponseDto<List<ItemDto>> result = new ResponseDto().buildSucceedHasData(data);
        return result;
    }
    /**
     * 下拉框 - 标签
     * @return
     */
    @RequestMapping("/getTag")
    @ResponseBody
    public ResponseDto<List<ItemDto>> getTag() {
        List<ItemDto> data = commonService.getTag();
        ResponseDto<List<ItemDto>> result = new ResponseDto().buildSucceedHasData(data);
        return result;
    }
}
